
#ifndef NETBASE_UTIL_H
#define NETBASE_UTIL_H

#define IMPL_NAME Impl

#define IMPL_DECL \
 public: \
  struct IMPL_NAME; \
 private: \
  IMPL_NAME* pimpl_;

#define IMPL_INIT(...) pimpl_(new IMPL_NAME(__VA_ARGS__))

#define IMPL_DELETE delete pimpl_;

#define IMPL_TYPE(classname) struct classname::IMPL_NAME

#define IMPL (*pimpl_)

#define IMPL_CAST(classname, var, arg) \
    classname::IMPL_NAME* var = static_cast<classname::IMPL_NAME*>(arg);

#define NONCOPYABLE(classname) \
    classname(const classname&); \
    classname& operator=(const classname&);

namespace net_base {
typedef void (*LogHandler)(const char* log, size_t len);

void SetLogHandler(LogHandler log_handler);

void __Internal_Log(const char* format, ...);
} // namespace net_base

#endif // NETBASE_UTIL_H

